<template>
  <div class="plan-wrap">
    <div class="plan-title">院校计划查询</div>
    <div class="plan-search">
      <i class="weui-icon-search i-search"></i>
      <input ref="searchIpt" type="search" autocomplete="off" class="search-ipt" v-model="planSchoolName" @keyup.enter="gotoPlanResult" placeholder="请输入您心仪的院校名称或院校国代/省代">
    </div>
    <div class="search-list" v-if="planSchoolName">
      <div class="result-nodata" v-if="!filterSchool.length">
        未找到相关的院校
      </div>
      <!-- <ul v-else-if="searchByCode && filterSchool.length == 1">
        <li  v-for="(item, idx) in filterSchool" :key="idx" @click="resultClick(item, idx)">
          {{item.value}}
        </li>
      </ul> -->
      <ul v-else>
        <li  v-for="(item, idx) in filterSchool" :key="idx" @click="resultClick(item, idx)">
          {{item.value}}
        </li>
      </ul>
    </div>
    <div class="plan-bg"></div>
  </div>
</template>

<script>
import planQueryMixins from './js/planQueryMixins'
export default {
  name: 'playQuery',
  mixins: [planQueryMixins],
  created () {
    this.planSchoolName="";
    this.originalToTbData()
  },
  watch: {
    planSchoolName () {
      if (this.searchByCode) {
        this.searchByCode = false
      } else {
        this.filterSchoolMethod(this.planSchoolName)
      }
    }
  },
  methods: {
    gotoPlanResult () {
      if (this.planSchoolName) {
        this.selectChange()
      } else {
        this.$vux.toast.show({
          text: '请输入您心仪的院校名称或院校国代/省代',
          type: 'text',
          width: '80%'
        })
      }
    },
    resultClick (item, idx) {
      // console.log(item, idx)
      this.planSchoolName = item.value
      this.selectChange()
    }
  },
  beforeDestroy () {
    this.rowData = null
    this.filterSchool = null
    this.majorTableData = null
  }
}
</script>

<style lang="scss" scoped>
.plan-wrap{
  padding: .266667rem /* 10/37.5 */ 0;
  padding-top: 10%;
  height: 100%;
  width: 100%;
  position: fixed;
  .plan-title{
    font-size: 20px;
	  color: #ff8600;
    margin-bottom: .213333rem /* 8/37.5 */;
    padding: 0 .4rem;
  }
  .plan-search{
    padding: .106667rem !important;
    position: relative;
    border: 1px solid #ff8600;
    border-radius: 0.13333rem;
    height: 0.96rem;
    margin: 0 .4rem;
    .i-search{
      position: absolute;
      left: .133333rem !important;
      top: 0;
      line-height: 0.85333rem;
      z-index: 9;
    }
    .search-ipt{
      border: none;
      width: 100%;
      height: 100%;
      position: absolute;
      left: 0;
      top: 0;
      padding-left: .8rem;
      font-size: 14px;
      padding-right: .3rem;
      border-radius: 0.13333rem;
    }
  }
  .search-list{
    overflow: auto;
    height: calc(100% - 3.15rem);
    padding: 0 0.4rem;
    margin: .2rem auto;
    li{
      font-size: 14px;
      padding: .266667rem /* 10/37.5 */ .4rem /* 15/37.5 */;
      position: relative;
      &.b{
        background-color: #ffeff0;
      }
      &.z{
        background-color: #edfbfe;
      }
      &:before{
        content: " ";
        position: absolute;
        left: 0;
        top: 0;
        right: 0;
        height: 1px;
        border-top: 1px solid #D9D9D9;
        color: #D9D9D9;
        -webkit-transform-origin: 0 0;
        transform-origin: 0 0;
        -webkit-transform: scaleY(0.5);
        transform: scaleY(0.5);
        left: 0;
      }
      .i-success{
        position: absolute;
        right: .4rem /* 15/37.5 */;
      }
    }
  }
  .result-nodata{
    font-size: 14px;
    color: #666;
    padding: 1.333333rem 0 0;
    text-align: center;
  }
  .plan-bg{
    background-image: url('../../assets/images/plan_bg.png');
    width: 100%;
    position: absolute;
    left: 0;
    bottom: 0;
    height: 4.666667rem /* 175/37.5 */;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: -1;
  }
}
</style>


